#include "systick.h"

extern uint8_t stop_sign_t;
extern uint32_t delay_time_stop;
extern uint32_t led_time;
extern uint32_t key_sign_time;

extern uint32_t adcdwncnt2;
	
void SysTick_Config_Init()
{
	/* SystemCoreClock / 1000    1ms中断一次
	* SystemCoreClock / 100000	 10us中断一次
	* SystemCoreClock / 1000000  1us中断一次
	*/
	if(SysTick_Config(SystemCoreClock/1000))
	{
	    while(1);
	}
}
void Delay_ms(__IO uint32_t nTime)
{ 
	TimingDelay = nTime;
	while(TimingDelay != 0);
}
void TimingDelay_Decrement(void)
{
  if (TimingDelay != 0x00)
  { 
    TimingDelay--;
  }
}

//定时器中断函数
void SysTick_Handler(void)
{    
	if (stop_sign_t == 1)
	{
		//开始停机模式
		if (delay_time_stop !=0)
		{
			delay_time_stop--;
		}
	}

	if (adcdwncnt2 != 0)
	{
		adcdwncnt2--;
	}
	

	if (key_sign_time !=0)
	{
		key_sign_time--;
	}
	
	//灯闪烁
	if( led_time != 0){
		led_time--;
	}
	

	TimingDelay_Decrement();
	
}

